package com.kool.kadmin.mqtt.dao;

import com.kool.kadmin.mqtt.bean.MqttTopicAuthDo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author luyu
 */
public interface MqttTopicAuthDao {
    /**
     * 插入
     *
     * @param mqttTopicAuthDo
     * @return
     */
    Integer insert(MqttTopicAuthDo mqttTopicAuthDo);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    MqttTopicAuthDo getById(@Param("id") Long id);

    /**
     * 批量插入
     *
     * @param list
     * @return
     */
    Integer batchInsert(List<MqttTopicAuthDo> list);

    /**
     * 更新
     *
     * @param mqttTopicAuthDo
     * @return
     */
    Integer updateById(MqttTopicAuthDo mqttTopicAuthDo);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    Integer deleteById(@Param("id") Long id);

    /**
     * 符合条件总条数
     *
     * @param mqttTopicAuthDo
     * @return
     */
    Integer countTotal(MqttTopicAuthDo mqttTopicAuthDo);

    /**
     * 分页查询
     *
     * @param condition
     * @param offset
     * @param rows
     * @return
     */
    List<MqttTopicAuthDo> getPage(@Param("condition") MqttTopicAuthDo condition, @Param("offset") int offset, @Param("rows") int rows);

    /**
     * 查询主题授权用户信息
     *
     * @param topicName
     * @param userName
     * @return
     */
    MqttTopicAuthDo getByTopicUserName(@Param("topicName") String topicName, @Param("userName") String userName);

    /**
     * 查询用户的主题权限
     *
     * @param userName
     * @return
     */
    List<MqttTopicAuthDo> getByUserName(@Param("userName") String userName);

    /**
     * 根据主题删除主题权限
     *
     * @param topicName
     * @return
     */
    int deleteByTopicName(@Param("topicName") String topicName);

    /**
     * 删除用户的主题权限
     *
     * @param userName
     * @return
     */
    int deleteByUserName(@Param("userName") String userName);
}
